<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/map.css" media="all">
    <script type="text/javascript" src='//webapi.amap.com/maps?v=1.4.6&key=9ab8eeffa6d88b5846afd39453c341b0&plugin=AMap.PlaceSearch,AMap.AdvancedInfoWindow'></script>
    <!-- UI组件库 1.0 -->
    <script src="//webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
</head>
<style type="text/css">
    .layui-table-view .layui-table {
        position: relative;
        width: 100%;
        margin: 0;
        margin-top: 0px;
        margin-right: 0px;
        margin-left: 0px;
    }
    
    .info-title {
        color: white;
        font-size: 14px;
        background-color: blue;
        line-height: 26px;
        padding: 0px 0 0 6px;
        font-weight: lighter;
        letter-spacing: 1px
    }
    
    .info-content {
        padding: 4px;
        color: #666666;
        line-height: 23px;
        font: 12px Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial;
    }
    
    .info-content img {
        float: left;
        margin: 3px;
    }
</style>

<body>

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md7">
                        <div class="layui-card">
                            <div class="layui-card-header" style=" font-size: 19px"><span class="arearegion"></span>医废收集情况图（统计日期：<span class="nowdate"></span>）</div>
                            <div class="layui-card-body" style="height: 750px;">
                                <div id="container" style="height: 100%;"></div>
                                <!-- <img src="../../layuiadmin/layui/images/hospital/24205015xtsi.jpg"> -->
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md5">
                        <div class="layui-col-md12">
                            <div class="layui-carousel" id="test1" lay-filter="test1">
                                <div carousel-item="">
                                    <div class="layui-card" style="background-color: white">
                                        <div class="layui-card-header" style=" font-size: 19px"><span class="arearegion"></span>每日产废量统计表（统计日期：<span class="nowdate"></span>）</div>
                                        <div class="layui-card-body  layui-text" style="height: 750px;">

                                            <div class="layui-col-md12">
                                                <table id="hour24-1" lay-filter="test"></table>
                                            </div>

                                            <div id="collectcount" style="width:100%;height: 390px; margin-top: 350px;  position: absolute;"></div>
                                        </div>
                                    </div>
                                    <div class="layui-card" style="background-color: white">
                                        <div class="layui-card-header" style=" font-size: 19px"><span class="arearegion"></span>本月产废量统计表（统计日期：<span class="nowmonth"></span>）</div>
                                        <div class="layui-card-body  layui-text" style="height: 324px;">

                                            <div class="layui-col-md12">
                                                <table id="hour24-3" lay-filter="test"></table>
                                            </div>

                                            <div id="collectcount1" style="width:687px;height: 390px; margin-top: 350px;  position: absolute;"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>


                    </div>
                </div>
            </div>
        </div>

        <script src="../../layuiadmin/layui/layui.js?t=1"></script>
        <script src="../../layuiadmin/layui/echarts.common.min.js"></script>
        <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>

        <script>
            layui.config({
                base: '../../layuiadmin/' //静态资源所在路径
            }).extend({
                index: 'lib/index' //主入口模块
            }).use(['index']);
            var $ = layui.$;
            layui.use('carousel', function() {
                var carousel = layui.carousel;
                //建造实例
                carousel.render({
                    elem: '#test1',
                    width: '100%', //设置容器宽度
                    autoplay: false,
                    height: '813px',
                    arrow: 'hover', //始终显示箭头
                    indicator: 'none'
                });
            });
        </script>
        <script type="text/javascript">
            var day1 = new Date();
            var s2 = day1.getFullYear() + "-" + addzreo(day1.getMonth() + 1) + "-" + addzreo(day1.getDate()); //今天
            day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000);
            var mon1 = day1.getMonth() + 1;
            var yesto = day1.getDate();

            function addzreo(a) {
                if (a < 10) {
                    a = "0" + a;
                }
                return a;
            }
            var s1 = day1.getFullYear() + "-" + addzreo(day1.getMonth() + 1) + "-" + addzreo(day1.getDate()); //昨天
            $(".nowdate").html(day1.getFullYear() + " 年 " + addzreo(day1.getMonth() + 1) + " 月 " + addzreo(day1.getDate()) + " 日");
            $(".nowmonth").html(day1.getFullYear() + " 年 " + addzreo(day1.getMonth() + 1) + " 月");
            var colors = [
                "#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00",
                "#b82e2e", "#316395", "#994499", "#22aa99", "#aaaa11", "#6633cc", "#e67300", "#8b0707",
                "#651067", "#329262", "#5574a6", "#3b3eac"
            ];
            var district, map = new AMap.Map('container', {
                cursor: 'default',
                resizeEnable: true,
                zoom: 12,
                mapStyle: 'amap://styles/a02e5ee9fde2d344d337ebca20b3f913'
            });
            var area;
            $.ajax({
                url: "../../../Cust/sessionRegion",
                type: "post",
                datatype: "json",
                success: function(res) {
                    switch (parseInt(res.data)) {
                        case 0:
                            $(".arearegion").html('上城区');
                            area = '上城区';
                            addHangZhou(area);
                            break;
                        case 1:
                            $(".arearegion").html('下城区');
                            area = '下城区';
                            addHangZhou(area);
                            break;
                        case 2:
                            $(".arearegion").html('江干区');
                            area = '江干区';
                            addHangZhou(area);
                            break;
                        case 3:
                            $(".arearegion").html('拱墅区');
                            area = '拱墅区';
                            addHangZhou(area);
                            break;
                        case 4:
                            $(".arearegion").html('西湖区');
                            area = '西湖区';
                            addHangZhou(area);
                            break;
                        case 5:
                            $(".arearegion").html('滨江区');
                            area = '滨江区';
                            addHangZhou(area);
                            break;
                        case 6:
                            $(".arearegion").html('萧山区');
                            area = '萧山区';
                            addHangZhou(area);
                            break;
                        case 7:
                            $(".arearegion").html('余杭区');
                            area = '余杭区';
                            addHangZhou(area);
                            break;
                        case 8:
                            $(".arearegion").html('桐庐县');
                            area = '桐庐县';
                            addHangZhou(area);
                            break;
                        case 9:
                            $(".arearegion").html('建德市');
                            area = '建德市';
                            addHangZhou(area);
                            break;
                        case 10:
                            $(".arearegion").html('富阳区');
                            area = '富阳区';
                            addHangZhou(area);
                            break;
                        case 11:
                            $(".arearegion").html('临安区');
                            area = '临安区';
                            addHangZhou(area);
                            break;
                        case 12:
                            $(".arearegion").html('淳安县');
                            area = '淳安县';
                            addHangZhou(area);
                            break;
                    }
                }
            })
            var infoWindow;


            $.ajax({
                url: '../../../Message/regionCollect',
                type: "post",
                datatype: "json",
                data: {
                    month: s2
                },
                success: function(res) {
                    $.ajax({
                        url: '../../../Message/regionCollect',
                        type: "post",
                        datatype: "json",
                        success: function(ress) {
                            infoWindow = new AMap.InfoWindow({
                                offset: new AMap.Pixel(0, 0)
                            });
                            for (var i = 0, marker; i < ress.data.length; i++) {

                                marker = new AMap.Marker({
                                    position: ress.data[i].LngLat.split(","),
                                    map: map
                                });
                                //本月
                                var all;
                                var tw;
                                for (var k = 0; k < res.data.length; k++) {
                                    if (res.data[k].name == ress.data[i].name) {
                                        all = parseInt(res.data[k].garbage) + parseInt(res.data[k].lwq) + parseInt(res.data[k].guil) + parseInt(res.data[k].yw) + parseInt(res.data[k].hx);
                                        tw = parseFloat(res.data[k].weight).toFixed(2);
                                    }
                                }

                                var all1 = 0; //昨日
                                for (var j = 0; j < res.data.length; j++) {
                                    if (res.data[j].hid == ress.data[i].hid) {
                                        all1 = parseInt(ress.data[i].garbage) + parseInt(ress.data[i].lwq) + parseInt(ress.data[i].guil) + parseInt(ress.data[i].yw) + parseInt(ress.data[i].hx);
                                    }
                                }

                                var content = "";
                                content = "<div><span style='font-size:19px;font-weight:bold;'>" + ress.data[i].name + "</span></div><br><img width='350' height='240' src='../../layuiadmin/layui/images/hospital/yy" + ress.data[i].hid + ".jpg' /><br/>";
                                content = content + "<div class='layui-tab layui-tab-brief'><ul class='layui-tab-title'><li class='layui-this'>本日医废收集情况</li><li>本月医废收集情况</li></ul><div class='layui-tab-content'><div class='layui-tab-item layui-show'style='font-size:14px' >本日共收集： <span style='font-weight:bold'>" + all1 + " </span>箱 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;重量为：<span style='font-weight:bold'>" + parseFloat(ress.data[i].weight).toFixed(2) + " </span>公斤</div><div class='layui-tab-item'style='font-size:14px'>本月共收集： <span style='font-weight:bold'>" + all + " </span>箱 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;重量为：<span style='font-weight:bold'>" + tw + " </span>公斤</div></div></div>";
                                marker.content = content;
                                marker.setTitle(ress.data[i].name);
                                marker.setLabel({ //label默认蓝框白底左上角显示，样式className为：amap-marker-label
                                    offset: new AMap.Pixel(20, 20), //修改label相对于maker的位置
                                    content: ress.data[i].name
                                });

                                marker.on('click', markerClick);


                            }

                            function markerClick(e) {
                                infoWindow.setContent(e.target.content);
                                infoWindow.open(map, e.target.getPosition());
                            }
                        }

                    })
                }
            })







            function addHangZhou(area) {
                //加载行政区划插件
                AMap.service('AMap.DistrictSearch', function() {
                    var opts = {
                        subdistrict: 1, //返回下一级行政区
                        extensions: 'all', //返回行政区边界坐标组等具体信息
                        level: 'city' //查询行政级别为 市
                    };
                    AMap.plugin(['AMap.ToolBar', 'AMap.Scale'], function() {
                            map.addControl(new AMap.ToolBar());
                            map.addControl(new AMap.Scale());
                        })
                        //实例化DistrictSearch
                    district = new AMap.DistrictSearch(opts);
                    district.setLevel('district');
                    //行政区查询
                    district.search(area, function(status, result) {
                        var bounds = result.districtList[0].boundaries;
                        var polygons = [];
                        if (bounds) {
                            for (var i = 0, l = bounds.length; i < l; i++) {
                                //生成行政区划polygon
                                var polygon = new AMap.Polygon({
                                    map: map,
                                    strokeWeight: 1,
                                    path: bounds[i],
                                    fillOpacity: 0.7,
                                    fillColor: '#CCF3FF',
                                    strokeColor: '#CC66CC'
                                });
                                polygons.push(polygon);
                            }
                            map.setFitView(); //地图自适应

                        }
                    });


                });
            }


            $.ajax({
                url: "../../../Message/regionCollect",
                type: "post",
                datatype: "json",
                success: function(res) {
                    var json = [];
                    for (var i = 0; i < res.data.length; i++) {
                        var all = parseInt(res.data[i].garbage) + parseInt(res.data[i].lwq) + parseInt(res.data[i].yw) + parseInt(res.data[i].hx) + parseInt(res.data[i].guil);

                        json.push({
                            'name': res.data[i].name,
                            'value': all,
                            'weight': res.data[i].weight == null || res.data[i].weight == " " || res.data[i].weight == undefined ? 0 : parseFloat(res.data[i].weight).toFixed(2)
                        })
                    }

                    layui.use('table', function() {
                        var table = layui.table;
                        var $ = layui.$;
                        table.render({
                            elem: '#hour24-1',
                            height: 'full',
                            data: json,
                            limit: 20,
                            cols: [
                                [
                                    //表头
                                    {
                                        field: 'name',
                                        title: '医院名称',
                                        width: '49%',
                                        align: 'center',
                                        style: 'height:1px;'

                                    }, {
                                        field: 'value',
                                        title: '数量（箱）',
                                        width: '25%',
                                        align: 'center'

                                    }, {
                                        field: 'weight',
                                        title: '重量（公斤）',
                                        width: '25%',
                                        align: 'center',
                                        templet: function(d) {
                                            if (d.weight == "" || d.weight == null || d.weight == undefined) {
                                                return "0.00"
                                            } else {
                                                return parseFloat(d.weight).toFixed(2)
                                            }
                                        }

                                    }
                                ]
                            ],
                            skin: 'row' //表格风格
                                ,
                            even: true
                        });
                        $("table th").css({
                            "background": "#1E9FFF",
                            "color": "white"
                        });
                    });
                    var lname = [];
                    for (var j = 0; j < json.length; j++) {
                        lname[j] = json[j].name
                    }


                    var mychart = echarts.init($("#collectcount")[0]);
                    var option = {
                        color: colors,
                        title: {
                            text: '区县内各医院昨日产废量分布图',

                            x: 'left'
                        },
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} 箱 (占比：{d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            top: 'middle',
                            type: 'scroll',
                            data: lname
                        },
                        series: [{
                            name: '产废量收集情况',
                            type: 'pie',
                            radius: '80%',
                            center: ['60%', '50%'],
                            data: json,
                            selectedMode: 'single',
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }],

                    };
                    mychart.setOption(option);
                },
                error: function(res) {
                    layui.use('table', function() {
                        var table = layui.table;
                        var $ = layui.$;
                        table.render({
                            elem: '#hour24-1',
                            height: 'full',
                            data: [],
                            limit: 20,
                            cols: [
                                [
                                    //表头
                                    {
                                        field: 'name',
                                        title: '医院名称',
                                        width: '49%',
                                        align: 'center',
                                        style: 'height:1px;'

                                    }, {
                                        field: 'value',
                                        title: '数量（箱）',
                                        width: '25%',
                                        align: 'center'

                                    }, {
                                        field: 'weight',
                                        title: '重量（公斤）',
                                        width: '25%',
                                        align: 'center'

                                    }
                                ]
                            ],
                            skin: 'row' //表格风格
                                ,
                            even: true
                        });
                        $("table th").css({
                            "background": "#1E9FFF",
                            "color": "white"
                        });
                    });

                }

            });
            $.ajax({
                url: "../../../Message/regionCollect",
                type: "post",
                datatype: "json",
                data: {
                    month: s2
                },
                success: function(res) {
                    var json4 = [];
                    for (var i = 0; i < res.data.length; i++) {
                        //num_0 garbage 感染性  num_1 lwq 损伤性  num_3 guil病理性  num_4 yw 药物性 hx num_5  化学性
                        var all = parseInt(res.data[i].garbage) + parseInt(res.data[i].lwq) + parseInt(res.data[i].guil) + parseInt(res.data[i].yw) + parseInt(res.data[i].hx);
                        json4.push({
                            'name': res.data[i].name,
                            'value': all,
                            'weight': res.data[i].weight == null || res.data[i].weight == " " || res.data[i].weight == undefined ? 0 : parseFloat(res.data[i].weight).toFixed(2)
                        })
                    }
                    var lname = [];
                    for (var j = 0; j < json4.length; j++) {
                        lname[j] = json4[j].name
                    }
                    var mychart1 = echarts.init($("#collectcount1")[0]);
                    var option1 = {
                        color: colors,
                        title: {
                            text: '区县内各医院本月产废量分布图',

                            x: 'left'
                        },
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} 箱 (占比：{d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            top: 'middle',
                            data: lname
                        },
                        series: [{
                            name: '产废量收集情况',
                            type: 'pie',
                            radius: '80%',
                            center: ['60%', '50%'],
                            data: json4,
                            selectedMode: 'single',
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }]
                    };
                    mychart1.setOption(option1);
                    layui.use('table', function() {
                        var table = layui.table;
                        var $ = layui.$;
                        table.render({
                            elem: '#hour24-3',
                            height: 'full',
                            data: json4,

                            cols: [
                                [
                                    //表头
                                    {
                                        field: 'name',
                                        title: '医院名称',
                                        width: 340,
                                        align: 'center'


                                    }, {
                                        field: 'value',
                                        title: '数量（箱）',
                                        width: 150,
                                        align: 'center'

                                    }, {
                                        field: 'weight',
                                        title: '重量（公斤）',
                                        width: 150,
                                        align: 'center',
                                        templet: function(d) {
                                            if (d.weight == "" || d.weight == null || d.weight == undefined) {
                                                return "0.00"
                                            } else {
                                                return parseFloat(d.weight).toFixed(2)
                                            }
                                        }

                                    }
                                ]
                            ],
                            skin: 'row' //表格风格
                                ,
                            even: true
                        });
                        $("table th").css({
                            "background": "#1E9FFF",
                            "color": "white"
                        });
                    });



                },
                error: function(res) {
                    layui.use('table', function() {
                        var table = layui.table;
                        var $ = layui.$;
                        table.render({
                            elem: '#hour24-3',
                            height: 'full',
                            data: [],

                            cols: [
                                [
                                    //表头
                                    {
                                        field: 'name',
                                        title: '医院名称',
                                        width: 340,
                                        align: 'center'


                                    }, {
                                        field: 'value',
                                        title: '数量（箱）',
                                        width: 150,
                                        align: 'center'

                                    }, {
                                        field: 'weight',
                                        title: '重量（公斤）',
                                        width: 150,
                                        align: 'center'

                                    }
                                ]
                            ],
                            skin: 'row' //表格风格
                                ,
                            even: true
                        });
                        $("table th").css({
                            "background": "#1E9FFF",
                            "color": "white"
                        });
                    });
                }

            })
        </script>
</body>

</html>